'use strict';
/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    await queryInterface.createTable('projects', {
      id: {
        allowNull: false,
        autoIncrement: true,
        primaryKey: true,
        type: Sequelize.INTEGER
      },
      title: {
        type: Sequelize.STRING
      },
      description: {
        type: Sequelize.TEXT
      },
      status_id: {  
        type: Sequelize.INTEGER,  
        allowNull: false,  
        references: {  
          model: 'statuses',  
          key: 'id'  
        },  
        onUpdate: 'CASCADE',  
        onDelete: 'RESTRICT' // 或者根据需要选择删除策略  
      },  
      category_id: {  
        type: Sequelize.INTEGER,  
        allowNull: false,  
        references: {  
          model: 'categories',  
          key: 'id'  
        },  
        onUpdate: 'CASCADE',  
        onDelete: 'RESTRICT' // 或者根据需要选择删除策略  
      },  
      createdAt: {
        allowNull: false,
        type: Sequelize.DATE
      },
      updatedAt: {
        allowNull: false,
        type: Sequelize.DATE
      }
    });
  },
  async down(queryInterface, Sequelize) {
    await queryInterface.dropTable('projects');
  }
};